const Router = require('express')
const Mock = require('mockjs')
const router = Router()
router.get('/api/v4/login', (req, res) => {
  const {
    username,
    password
  } = req.body
  const err = []
  if (!username) {
    err.push('用户名错误')
  }
  if (!password) {
    err.push('密码错误')
  }
  if (err.length > 0) {
    res.json({
      code: 200,
      errorMsg: 'FAILED',
      data: err
    })
  }
  res.json({
    code: 200,
    errorMsg: 'OK',
    data: Mock.mock({
      id: '@id',
      token: '@uuid',
      username: '@cname'
    })
  })
})

module.exports = router
